/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fix.it.source.fixit;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Biserka
 */
@Entity
@Table(name = "LOCALUSER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Localuser.findAll", query = "SELECT l FROM Localuser l"),
    @NamedQuery(name = "Localuser.findById", query = "SELECT l FROM Localuser l WHERE l.id = :id"),
    @NamedQuery(name = "Localuser.findByUsername", query = "SELECT l FROM Localuser l WHERE l.username = :username"),
    @NamedQuery(name = "Localuser.findByPassword", query = "SELECT l FROM Localuser l WHERE l.password = :password"),
    @NamedQuery(name = "Localuser.findByFirstname", query = "SELECT l FROM Localuser l WHERE l.firstname = :firstname"),
    @NamedQuery(name = "Localuser.findBySecondname", query = "SELECT l FROM Localuser l WHERE l.secondname = :secondname"),
    @NamedQuery(name = "Localuser.findByEmail", query = "SELECT l FROM Localuser l WHERE l.email = :email"),
    @NamedQuery(name = "Localuser.findByFirstregistration", query = "SELECT l FROM Localuser l WHERE l.firstregistration = :firstregistration"),
    @NamedQuery(name = "Localuser.findByIsactive", query = "SELECT l FROM Localuser l WHERE l.isactive = :isactive")})
public class Localuser implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userid")
    private Collection<Problem> problemCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "USERNAME")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "PASSWORD")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "FIRSTNAME")
    private String firstname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "SECONDNAME")
    private String secondname;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FIRSTREGISTRATION")
    @Temporal(TemporalType.DATE)
    private Date firstregistration;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ISACTIVE")
    private int isactive;

    public Localuser() {
    }

    public Localuser(Long id) {
        this.id = id;
    }

    public Localuser(Long id, String username, String password, String firstname, String secondname, String email, Date firstregistration, int isactive) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.firstname = firstname;
        this.secondname = secondname;
        this.email = email;
        this.firstregistration = firstregistration;
        this.isactive = isactive;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getSecondname() {
        return secondname;
    }

    public void setSecondname(String secondname) {
        this.secondname = secondname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getFirstregistration() {
        return firstregistration;
    }

    public void setFirstregistration(Date firstregistration) {
        this.firstregistration = firstregistration;
    }

    public int getIsactive() {
        return isactive;
    }

    public void setIsactive(int isactive) {
        this.isactive = isactive;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Localuser)) {
            return false;
        }
        Localuser other = (Localuser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fix.it.source.fixit.Localuser[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<Problem> getProblemCollection() {
        return problemCollection;
    }

    public void setProblemCollection(Collection<Problem> problemCollection) {
        this.problemCollection = problemCollection;
    }
    
}
